<!--<a href="#/layui/memberList" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: 20px 0 0 100px;">
  <i class="layui-icon">&#xe65c;</i>
</a>-->

<form class="layui-form" action="">
		<div class="layui-fluid">
			<div class="layui-card">
				<div class="layui-row">
		    <div class="layui-col-xs12">
		    	<div class="layui-card-header">
		    		<h2>编辑会员</h2>
		      	
		      </div>
		      <div class="layui-card-body">
		     <form action="" class="layui-form">
		      	<div class="layui-card-body">
		      		<div class="layui-form-item">
			      			<div class="layui-form-label">会员ID：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="memberId" required disabled class="layui-input memberId">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">会员姓名：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="memberName" required  class="layui-input memberName">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">公司：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="company" class="layui-input company">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">邮箱：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="Email" class="layui-input Email">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">微信：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="WxId" class="layui-input WxId">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">职业名称：</div>
			      			<div class="layui-input-block">
			      				 <select name="jobsName" lay-verify="required" id="jobsName" class="jobsName" lay-filter="jobs_name">
							        <option value="">请选择</option>
							      </select>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">一级行业：</div>
			      			<div class="layui-input-block">
			      				 <select name="fristJobs" class="fristJobs" lay-verify="required" lay-filter="fristJobs">
							        <option value="">请选择</option>
							      </select>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">二级行业：</div>
			      			<div class="layui-input-block">
			      				 <select name="secJobs" class="secJobs" id="secJobs" lay-verify="required" lay-filter="secJobs">
							        <option value="">请选择</option>
							      </select>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
		      			<div class="layui-form-label">城市：</div>
		      			<div class="layui-input-block clearfix">
		      				 <div class="select200 fl">
					      				<select name="province" class="province" lay-verify="required" required lay-filter="province">
												  <option value="">省份</option>
												</select> 
					      			</div>
					      			<div class="select200 fl">
					      				<select name="city" class="city" lay-verify="required" required lay-filter="city">
													  <option value="">城市</option>
													</select> 
					      			</div>
					      			<div class="select200 fl">
					      				<select name="area" class="Area" lay-verify="required" required lay-filter="Areas">
															  <option value="">区域</option>
															</select> 
					      			</div>
		      			</div>
		      		</div>
		      		<div class="layui-form-item">
			      			<div class="layui-form-label">地址：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="addr" class="layui-input addr">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">手机号：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="memberPhone" required class="layui-input memberPhone">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">业务介绍：</div>
			      			<div class="layui-input-block">
			      				 <textarea type="text" name="Brief" required  class="layui-textarea Brief"></textarea>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">分享资源：</div>
			      			<div class="layui-input-block">
			      				 <textarea type="text" name="SharedResource" required  class="layui-textarea SharedResource"></textarea>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">需求资源：</div>
			      			<div class="layui-input-block">
			      				 <textarea type="text" name="DemandResources" required  class="layui-textarea DemandResources"></textarea>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
	      			<div class="layui-form-label">宣传图片：</div>
	      			<div class="layui-input-block prodDetail">
	      				<table class="layui-table" lay-size="lg" lay-skin="nob">
				      				<tbody>
				      					<tr>
				      						<td class="prodDe_td" lay-filter="xiangqing">
				      						</td>
				      						<!--<td>
												<button class="layui-btn layui-btn-danger cover_delPic">删除</button>
				      						</td>-->
				      					</tr>
				      					<tr>
				      						<td>
				      							<input type="file" class="detail_input" style="display: none;" onchange="uploadPhoto3(this)">   
				      						
				      							<button type="button" class="layui-btn" id="test1" onclick="coverDetail()">
															  <i class="layui-icon">&#xe67c;</i>添加图片
															</button>
														<button class="layui-btn layui-btn-danger delDeImg" type="button">删除</button> 
				      						</td>
				      					</tr>
				      				</tbody>
				      			</table>
	      			</div>
	      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">是否推荐：</div>
			      			<div class="layui-input-block">
			      				 <select name="IsRecommend" class="IsRecommend">
							        <option value="0">否</option>
							        <option value="1">是</option>
							      </select>
			      			</div>
			      		</div>
			      		<!--<div class="layui-form-item">
			      			<div class="layui-form-label">推荐人：</div>
			      			<div class="layui-input-block">
			      				 <input type="text" name="tuijianren" required class="layui-input tuijianren">
			      			</div>
			      		</div>-->
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">消息标题：</div>
			      			<div class="layui-input-block clearfix">
			      				
			      				 <input type="text" name="xiaoxiTitle"  class="layui-input input33 xiaoxiTitle fl">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">发送消息：</div>
			      			<div class="layui-input-block clearfix">
			      				
			      				 <input type="text" name="xiaoxi"  class="layui-input input33 xiaoxi fl">
			      				 <button class="layui-btn fl fasong" type="button">发送</button>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">推荐人手机：</div>
			      			<div class="layui-input-block clearfix">
			      				
			      				 <input type="text" name="FatherName"  class="layui-input input33 FatherName fl">
			      				 <button class="layui-btn fl searchTel" type="button">搜索</button>
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label"></div>
			      			<div class="layui-input-block">
			      				
			      				 <div class="searchResult" id="searchResult" ></div>
			      				 <!--<input type="radio" name="father" lay-filter="jieguo" title="1" value="1" />
			      				 <input type="radio" name="father" lay-filter="jieguo" title="2" value="2" />-->
			      			</div>
			      		</div>
		      	</div>
		      	
		      	
		      	
		      	
		      	<!--<table class="layui-table" lay-size="lg" style="table-layout:fixed" lay-skin="nob">
		      		<colgroup>
					    <col width="50">
					    <col width="500">
					  </colgroup>
				   <tbody>
				   		<tr>
				   			<td>会员ID：</td>
				   			<td><input type="text" name="memberId" required  class="layui-input memberId input33"></td>
				   		</tr>
				   		<tr>
				   			<td>会员姓名：</td>
				   			<td><input type="text" name="memberName" required  class="layui-input memberName input33"></td>
				   		</tr>
				   		<tr>
				   			<td>职业名称：</td>
				   			<td>
				   				<div class="select25">
					   				<select name="jobsName" lay-verify="required" id="jobsName" class="jobsName" lay-filter="jobs_name">
							        <option value="">请选择</option>
							      </select>
						      </div>
				   			</td>
				   		</tr>
				   		<tr>
				   			<td>一级行业：</td>
				   			<td>
				   				<div class="select25">
					   				<select name="fristJobs" class="fristJobs" lay-verify="required" lay-filter="fristJobs">
							        <option value="">请选择</option>
							      </select>
						      </div>
				   			</td>
				   		</tr>
				   		<tr>
				   			<td>二级行业：</td>
				   			<td>
				   				<div class="select25">
					   				<select name="secJobs" class="secJobs" id="secJobs" lay-verify="required" lay-filter="secJobs">
							        <option value="">请选择</option>
							      </select>
						      </div>
				   			</td>
				   		</tr>
				   		<tr>
				   			<td>会员手机号：</td>
				   			<td><input type="text" name="memberPhone" required class="layui-input memberPhone input33"></td>
				   		</tr>
				   </tbody>   
				      
				      	
			      </table>-->
			      
			      <div class="save-warp">
			      	<a href="#/layui/memberList" class="btn layui-btn layui-btn-primary"  type="button">返回</a>
			      	<button class="addLevBtn layui-btn saveBtn" name="saveBtn" type="button">保存</button>
			      	
			      </div>
						
			      
		      	</form>
		      
		      
		    </div>
    
		</div>
		
	
		
		
	</div>
</form>
</div>

<script type="text/javascript" src="../../api/DBHelper.js"></script>
<script type="text/javascript">
	//重新渲染表单
function renderForm(){
  layui.use('form', function(){
   var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
   form.render();
  });
}
let fristJobs = document.querySelector(".fristJobs");
let secJobs = document.querySelector(".secJobs");
let jobsName = document.querySelector(".jobsName");
let saveBtn = document.querySelector(".saveBtn");
let memberId = document.querySelector(".memberId");
let memberName = document.querySelector(".memberName");
let memberPhone = document.querySelector(".memberPhone");
let xiaoxi = document.querySelector(".xiaoxi");
let fasong = document.querySelector(".fasong");
let company = document.querySelector(".company");
let searchTel = document.querySelector(".searchTel");
let FatherName = document.querySelector(".FatherName");
let IsRecommend = document.querySelector(".IsRecommend");
let Brief = document.querySelector(".Brief");
let SharedResource = document.querySelector(".SharedResource");
let DemandResources = document.querySelector(".DemandResources");
let province = document.querySelector(".province");
let WxId = document.querySelector(".WxId");
let Email = document.querySelector(".Email");
let city = document.querySelector(".city");
let Areas = document.querySelector(".Area");
let addr = document.querySelector(".addr");
let xiaoxiTitle = document.querySelector(".xiaoxiTitle");
let photo = '';
let cityCode = '';
let areaCode = "";
let areas = "";
let fenhuiArea = document.querySelector(".fenhuiArea");
let sheng = '';
let shi = "";
let qu = "";
let ciArr = [];

let prodDe_td = document.querySelector(".prodDe_td")
let photos = [];
let delDeImg = document.querySelector(".delDeImg")
let fatherId = '';
let temp='';
let seFrist="";
let seSec="";
let seSecText="";
let job="";

let _Mobj = {
	      	"Guid": "00000000-0000-0000-0000-000000000000",
			  "Title": "",
			  "Type": "",
			  "Content": "",
			  "LoginId": localStorage.getItem("user"),
			  "CreateTime": "",
			  "IsDeleted": 0
	      }

//	详情图
	function coverDetail(){
		$('.detail_input').click()
	}
	
	//	删除按钮,修改delDeImg和prodDe_check
	delDeImg.addEventListener("click",function(){
		
			$.each($('input[name="prodDe_check"]:checked'),function(){
				photos.splice(photos.indexOf($(this).val()),1)
				console.log("$(this)",$(this).parent().remove())
			})
//			console.log(photos)
	})
//	每一个多图上传的方法都不一样,回调函数内容不一样
	function uploadPhoto3(file) {
    console.log(file.files[0])

    var data = new FormData();
    data.append("file", file.files[0]);
    

    $.ajax({
      url:DBHelper.host+'/api/ImgUpload?MemLoginId=admit&ImagesType=',
      type: 'POST',
      dataType: 'JSON',
      data: data,
      cache: false,
      processData: false,
      contentType: false,
      beforeSend: function(request) {
          request.setRequestHeader("Authorization", 'bearer ' + DBHelper.getToken());
          loadingImg()
      },
			success:function(res){
//				let fhImg = document.querySelector(".fhImg");
//				console.log(res.Url)
//				fhImg.setAttribute("src",res.Url)
//				photo = res.Url;
//				prodBg.setAttribute("src",res.Url)
				prodDe_td.innerHTML += `
				<div class="prodDe_check">
					<img src="${res.Url}" style="width: 100px;height: 100px;margin-bottom:20px;" />
					<input type="checkbox" name="prodDe_check" lay-skin="primary" value="${res.Url}">
				</div>
				
				`
				renderForm();
				photos.push(res.Url);
				$('.loading').remove()
//					console.log(res)
				console.log(photos)
			},
			error:function(res){
				$('.loading').remove()
			}
    })
  }
//	将图片转换成json串
	function jointPic(arr){
		let sum = '';
		arr.forEach((el,index)=>{
			sum += el+"|"
		})
		sum = sum.substring(0,sum.length-1)
		return sum;
	}




layui.use(['jquery', 'mockjs', 'table', 'sidebar', 'form','route'], function () {
		var $ = layui.jquery,
      layer = layui.layer,
      table = layui.table,
      sidebar = layui.sidebar,
      route = layui.route,
      params = route.params(),
      form = layui.form;
      
      let _obj = {
				Guid:'00000000-0000-0000-0000-000000000000',
		  	MemLoginId:memberId.value,	
		  	Pwd:'',
		  	NickName:'',
		  	RealName:memberName.value,
		  	MaxPhoto:'',
		  	MinPhoto:'',
		  	MultiPhoto:'',
		  	Mobile:memberPhone.value,
		  	Email:'',
		  	RankScore:'',
		  	RankGuid:'00000000-0000-0000-0000-000000000000',
		  	WxId:'',
		  	Company:'',
		  	CompanyArea:'',
		  	CompanyAreaCode:'',
		  	CompanyAddress:'',
		  	WWW:'',
		  	Area:'',
		  	AreaCode:'',
		  	Address:'',
		  	Position:job.value,
		  	Trade:"",
		  	TradeId:seSec.value,
		  	Brief:'',
		  	SharedResource:'',
		  	DemandResources:'',
		  	BrowseCount:'',
		  	CollectCount:'',
		  	TransmitCount:'',
		  	LikeCount:'',
		  	CreateUser:'',
		  	CreateTime:'',
		  	ModifyUser:localStorage.getItem("user"),
		  	ModifyTime:getNowFormatDate(),
		  	WxUnionId:'0'
			}
      
      
      
      form.on('radio(jieguo)',function(data){
      	console.log(1)
      	console.log(data.value)
      	console.log(data.elem.title)
      	fatherId = data.value;
      })
      
      //		显示默认的地址
      
      function defultArea(proCode,cityCode,AreaCode,baseUrl){
      	$.ajax({//异步请求返回给后台
		    	  url:baseUrl,
		    	  type:'get',
		    	  data:{FatherId:'0'},
		    	  dataType:'json',
		    	  beforeSend: function(request) {
			            
			            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
			        },
		    	  success:function(data){
		    		  //这里获取到数据执行显示
//		    		  console.log("地址data",data)
							let p = document.createElement('option');
							let proValue="";
							p.value='';
							p.innerText="省份";
		    		  data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	if(el.Code==proCode){
		    		  		proValue=el.ID;
		    		  	}
		    		  	
		    		  	op.value = el.ID;
		    		  	op.innerText = el.Name;
		    		  	province.appendChild(op)
//		    		  	console.log(op.id)
		    		  })
		    		  $(".province").find("option[value='"+proValue+"']").prop("selected",true);
		    		  
		    		  $.ajax({//异步请求返回给后台
				    	  url:baseUrl,
				    	  type:'get',
				    	  data:{FatherId:proValue},
				    	  dataType:'json',
				    	  beforeSend: function(request) {
			            
			            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
			        },
				    	  success:function(data){
				    		  //这里获取到数据执行显示
//				    		  console.log("地址data",data)


									ciArr = [...data];
									console.log("ciArr",ciArr)
									let p = document.createElement('option');
									let cityValue="";
									p.value='';
									p.innerText="城市";
				    		  data.forEach(function(el,index){
				    		  	let op = document.createElement('option');
				    		  	if(el.Code==cityCode){
				    		  		cityValue=el.ID;
//				    		  		console.log(el.)
				    		  	}
				    		  	
				    		  	op.value = el.ID;
				    		  	op.innerText = el.Name;
				    		  	city.appendChild(op) 
//				    		  	console.log(op.id)
				    		  })
				    		  $(".city").find("option[value='"+cityValue+"']").prop("selected",true);
				    		  renderForm();
				    		  
				    		  $.ajax({//异步请求返回给后台
							    	  url:baseUrl,
							    	  type:'get',
							    	  data:{FatherId:cityValue},
							    	  dataType:'json',
							    	  beforeSend: function(request) {
			            
			            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
			        },
							    	  success:function(data){
							    		  //这里获取到数据执行显示
//							    		  console.log("地址data",data)
												let p = document.createElement('option');
												let areaValue="";
												p.value='';
												p.innerText="城市";
							    		  data.forEach(function(el,index){
							    		  	let op = document.createElement('option');
							    		  	if(el.Code==AreaCode){
//							    		  		areaValue=el.ID;
//							    		  		console.log("el.areaValue",areaValue)
															
							    		  	}
							    		  	
							    		  	op.value = el.Code;
							    		  	op.innerText = el.Name;
							    		  	Areas.appendChild(op); 
			//				    		  	console.log(op.id)
							    		  })
							    		  $(".Area").find("option[value='"+AreaCode+"']").prop("selected",true);
							    		  renderForm();
							    		  
							    		  
							    		  
							    	  }
							    	  
							      });
				    		  renderForm();
				    	  }
				    	  
				      });
		    		  
		    		  
		    		  renderForm();
		    	  }
		    	  
		      });
		      
      }
      
      //    省市区三级
			takeArea();

      function takeArea(){
      	let proArr = [];
      	
      	$.ajax({//异步请求返回给后台
		    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion',
		    	  type:'get',
		    	  data:{FatherId:'0'},
		    	  dataType:'json',
		    	  beforeSend: function(request) {
			            
			            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
			        },
		    	  success:function(data){
		    	  	proArr = [...data]
		    		  //这里获取到数据执行显示
//		    		  console.log("地址data",data)
							let p = document.createElement('option');
							p.value='';
							p.innerText="省份";
		    		  data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	op.value = el.ID;
		    		  	op.innerText = el.Name;
		    		  	province.appendChild(op)
		    		  	
		    		  })
		    		  renderForm();
		    	  }
		    	  
		      });
		      
		      form.on('select(province)', function(data){
//		      	debugger
						cityCode = data;
						proArr.forEach((el,index)=>{
		      				if(el.ID==data.value){
		      					areaCode=el.Code;
		      					
		      				}
		      			})
						if(data.value==""){
		      				areaCode="";
		      			}
						console.log("areaCode",areaCode);
			//			console.log("seFrist",seFrist)
//					  console.log(data.value);
					  $.ajax({//异步请求返回给后台
					    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion',
					    	  type:'get',
					    	  data:{FatherId:data.value},
					    	  dataType:'json',
					    	  beforeSend: function(request) {
			            
			            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
			        },
					    	  success:function(data){
					    	  	
					    	  		ciArr = [...data];
					    	  	
					    	  	
					    		  //这里获取到数据执行显示
					    		  console.log(data)
			//		    		  console.log("secJobs",secJobs.length)
			//							secJobs="";
										$(".city").empty();
										let p = document.createElement('option');
										p.value = "";
										p.innerText = "城市";
										city.appendChild(p)
					    		  data.forEach((el,index)=>{
					    		  	let op = document.createElement('option');
					    		  	op.value = el.ID;
					    		  	op.innerText = el.Name;
			//		    		  	op.id = el.Id;
					    		  	city.appendChild(op)
					    		  })
					    		  renderForm();
					    		  
					    	  }
					    	  
					      });
					});   
					
					form.on('select(city)', function(data){
						let _city = data.value;
						console.log("_city",_city)
						AreaCode = data;
						console.log(1,data.value)
						if(data.value==""){
	      				areaCode=areaCode.substr(0,3);
	      				
	      			}
			//			console.log("seFrist",seFrist)
//					  console.log(data.value);
					  $.ajax({//异步请求返回给后台
					    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion',
					    	  type:'get',
					    	  data:{FatherId:data.value},
					    	  dataType:'json',
					    	  beforeSend: function(request) {
			            
			            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
			        },
					    	  success:function(data){
					    	  	console.log("ciArr",ciArr)
					    	  	ciArr.forEach((el,index)=>{
					    	  		
					    		  	if(el.ID==_city){
					    		  		areaCode=el.Code
					    		  		console.log(3,el.Code)
					    		  	}
					    		  })
					    	  	 console.log("areaCode",areaCode)
					    		  //这里获取到数据执行显示
					    		  console.log(data)
			//		    		  console.log("secJobs",secJobs.length)
			//							secJobs="";
										$(".Area").empty();
										let p = document.createElement('option');
										p.value = "";
										p.innerText = "区域";
										Areas.appendChild(p)
					    		  data.forEach((el,index)=>{
					    		  	let op = document.createElement('option');
					    		  	op.value = el.Code;
					    		  	op.innerText = el.Name;
			//		    		  	op.id = el.Id;
					    		  	Areas.appendChild(op)
					    		  })
					    		  renderForm();
					    		  
					    	  }
					    	  
					      });
					}); 
					
					
					
					form.on('select(Areas)', function(data){
//						areaCode = $(".Area option:selected").val();
//						areas = $(".province option:selected").text()+$(".city option:selected").text()+$(".Area option:selected").text();
							if(data.value!=""){
								areaCode = $(".Area option:selected").val();
		//							areas = $(".province option:selected").text()+$(".city option:selected").text()+$(".Area option:selected").text();
							}else{
								areaCode=areaCode.substr(0,6);
							}
						
						console.log("areaCode",areaCode);
						console.log("areas",areas)
					})
					
      }
      
      searchTel.addEventListener("click",function(){
      	
      	
      	if(FatherName.value!=''){
      		DBHelper.GetA("GetXn_MemberByMobile?Mobile="+FatherName.value,function(data){
      			console.log("成功",data)
      			if(data.length>=1){
      				$("#searchResult").empty();
      				data.forEach((el,index)=>{
      					
      					$("#searchResult").append('<input type="radio" lay-filter="jieguo" name="father" title="'+el.RealName+'" value="'+el.MemLoginId+'" />')
      				})
      			
//    				$("#searchResult").append('<div><button class="layui-btn">确定</button></div>')
      				
//    				layer.open({
//							  type: 1, 
//							  content:$("#searchResult").html()
////							  content: function(){
////							  	data.forEach((el,index)=>{
////								  	return '<div>'+el.RealName+'</div>'
////								  }) //这里content是一个普通的String
////							  }
//								
//							  
//							});
							form.render();
      			}else{
      				$("#searchResult").empty();
      				let index = layer.alert("没有该会员",function(){
      					layer.close(index)
      				})
      			}
      		},function(data){
      			console.log("失败",data)
      		})
      		
      		console.log($("input[type='radio'][name='father']"),5)
      				
				      	$("input[type='radio'][name='father']").click(function(){
				      				console.log(1)
				      				console.log($("input[type='radio'][name='father']:checkbox:checked").val())
				      			})
				     
      		
      	}
      })
      
//    职位名称
			renderForm();
			
//			DBHelper.Get("GetXn_Position", function(data){
//				console.log("职位",data)
//				data.forEach((el,index)=>{
//		    		  	let op = document.createElement('option');
//		    		  	op.value = el.Id;
//		    		  	op.innerText = el.Name;
//		    		  	jobsName.appendChild(op)
//		    		  	
//		    		  })
//			})
			
//			form.on('select(jobs_name)', function(data){
//				jobsName = data.value;
//			})
			
			$.ajax({//异步请求返回给后台
		    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_Position',
		    	  type:'get',
		    	  data:{},
		    	  beforeSend: function(request) {
//		            loadingImg()
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
		    	  dataType:'json',
		    	  async:false,
		    	  success:function(data){
		    		  //这里获取到数据执行显示
//		    		  console.log(data)
		    		  data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	op.value = el.Name;
		    		  	op.innerText = el.Name;
		    		  	jobsName.appendChild(op);
		    		  	
		    		  	
		    		  	
		    		  	
		    		  	
		    		  })
		    		  renderForm();
		    		  
		    	  }
		    	  
		      });
			
//		      一二级行业
		$.ajax({//异步请求返回给后台
		    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_Trade',
		    	  type:'get',
		    	  data:{FatherId:'00'},
		    	  beforeSend: function(request) {
//		            loadingImg()
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
		    	  dataType:'json',
		    	  async:false,
		    	  success:function(data){
		    	  	console.log(data)
		    		  //这里获取到数据执行显示
//		    		  console.log(data)
		    		  data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	op.id = el.Id;
		    		  	op.value = el.Code;
		    		  	op.innerText = el.Name;
		    		  	fristJobs.appendChild(op)
		    		  	
		    		  })
		    		  renderForm();
		    	  }
		    	  
		      });
			
			

      
		      

		      
		form.on('select(fristJobs)', function(data){
			console.log(data.value)
			seFrist = data;
//			console.log("seFrist",seFrist)
//		  console.log(data.value);
		  $.ajax({//异步请求返回给后台
		    	  url:'https://xnsmb.xnsoft.net.cn/api/GetXn_Trade',
		    	  type:'get',
		    	  data:{FatherId:data.value},
		    	  dataType:'json',
		    	  beforeSend: function(request) {
//		            loadingImg()
		            request.setRequestHeader("Authorization", 'bearer ' + localStorage.getItem("token"));
		        },
		    	  
		    	  success:function(data){
		    	  	
		    		  //这里获取到数据执行显示
//		    		  console.log(data)
//		    		  console.log("secJobs",secJobs.length)
//							secJobs="";
							$("#secJobs").empty();
							let p = document.createElement('option');
							p.value = "";
							p.innerText = "请选择";
							secJobs.appendChild(p)
		    		  data.forEach((el,index)=>{
		    		  	let op = document.createElement('option');
		    		  	op.id = el.Id;
		    		  	op.value = el.Code;
		    		  	op.innerText = el.Name;
//		    		  	op.id = el.Id;
		    		  	secJobs.appendChild(op)
		    		  })
		    		  renderForm();
		    		  
		    	  }
		    	  
		      });
		});   
		
		
		form.on('select(secJobs)', function(data){
			console.log(data.value)
			seSec = data;
//			console.log("seSec",seSec)
//			console.log("seSec",data.elem[data.elem.selectedIndex].id)
			seSecText = data.elem[data.elem.selectedIndex].text;
//			console.log("seSecText",seSecText)
			
		})
		form.on('select(jobsName)', function(data){
			job = data;
//			console.log("job",job)
//			console.log("data.value",data.value);
		})
		
		if(params){
			DBHelper.GetA("Admin_Xn_Member?id="+params.id, function(data){
				console.log("本页信息",data)
				_obj = data;
				console.log("data.IsRecommend",data.IsRecommend)
				$(".IsRecommend").find("option[value='"+data.IsRecommend+"']").prop("selected",true);
				renderForm();
				areaCode = data.AreaCode;
				fatherId = data.FatherId;
				memberId.value = data.MemLoginId;
				memberName.value = data.RealName;
				addr.value = data.Address;
				memberPhone.value = data.Mobile;
				Brief.value = data.Brief;
				SharedResource.value = data.SharedResource;
				DemandResources.value = data.DemandResources;
				Email.value = data.Email;
				WxId.value = data.WxId;
				
				company.value = data.Company;
				temp = data.TradeId;
				id = data.MemLoginId;
				
				fasong.addEventListener("click",function(){
					_Mobj.Title = xiaoxiTitle.value;
					_Mobj.Content = xiaoxi.value;
					_Mobj.CreateTime = getNowFormatDate();
					DBHelper.Post("Admin_Xn_MessageInfo",_Mobj,function(data){
						let mesId = data.Guid;
						DBHelper.PostArr("Admin_Xn_MessageInfo?xn_MessageInfoGuid="+mesId,[id],function(data){
								  			console.log("发送成功",data)
								  			let index = layer.alert("发送成功",function(){
								  				layer.close(index)
								  			})
								  			
								  		},function(data){
								  			console.log("发送失败",data) 
								  		})
					})
				})
				
//				默认地址
				let proCode = "";
				let cityCode = "";
				if(data.AreaCode!=null){
					proCode = data.AreaCode.substr(0,3);
      		cityCode = data.AreaCode.substr(0,6);
				}
				
      		
      		console.log("proCode",proCode);
      		console.log("cityCode",cityCode);
      		defultArea(proCode,cityCode,data.AreaCode,'https://xnsmb.xnsoft.net.cn/api/GetXn_DispatchRegion');
				
				$(".jobsName").find("option[value='"+data.Position+"']").prop("selected",true);
				console.log(99,data.TradeId)
				if(data.TradeId!=null){
					$(".fristJobs").find("option[value='"+data.TradeId.substr(0,3)+"']").prop("selected",true);
				}
				
				
				console.log($("select[name='fristJobs'] option:checked").attr("id"))
				DBHelper.Get("GetXn_Trade?FatherId="+$("select[name='fristJobs'] option:selected").val(),function(data){
//					console.log(data)
					$("#secJobs").empty();
					let p = document.createElement('option');
					p.value = "";
					p.innerText = "请选择";
					secJobs.appendChild(p)
    		  data.forEach((el,index)=>{
    		  	let op = document.createElement('option');
//  		  	op.id = el.Id;
    		  	op.value = el.Code;
    		  	op.innerText = el.Name;
//		    		  	op.id = el.Id;
    		  	secJobs.appendChild(op)
    		  })
    		  renderForm();
//  		  console.log("data.TradeId",data.TradeId)
    		  $(".secJobs").find("option[value='"+temp+"']").prop("selected",true);
    		  renderForm();
				},function(data){
					console.log(data)
				})
				
				_obj = {
						Guid:'00000000-0000-0000-0000-000000000000',
				  	MemLoginId:memberId.value,	
				  	Pwd:'',
				  	NickName:'',
				  	RealName:memberName.value,
				  	MaxPhoto:'',
				  	MinPhoto:'',
				  	MultiPhoto:'',
				  	Mobile:memberPhone.value,
				  	Email:'',
				  	RankScore:'',
				  	RankGuid:'00000000-0000-0000-0000-000000000000',
				  	WxId:'',
				  	Company:'',
				  	CompanyArea:'',
				  	CompanyAreaCode:'',
				  	CompanyAddress:'',
				  	WWW:'',
				  	Area:'',
				  	AreaCode:'',
				  	Address:'',
				  	Position:job.value,
				  	Trade:seSecText,
				  	TradeId:seSec.value,
				  	Brief:'',
				  	SharedResource:'',
				  	DemandResources:'',
				  	BrowseCount:'',
				  	CollectCount:'',
				  	TransmitCount:'',
				  	LikeCount:'',
				  	CreateUser:'',
				  	CreateTime:'',
				  	ModifyUser:localStorage.getItem("user"),
				  	ModifyTime:getNowFormatDate(),
				  	WxUnionId:'0'
					}
				_obj = data;
				
				//    		多图下载到本地,修改DetailsImage,prodDe_check,prodDe_td
      		if(data.MultiPhoto){
      			photos = data.MultiPhoto.split("|");
	      		photos.forEach((el,index)=>{
	      			prodDe_td.innerHTML += `
							<div class="prodDe_check">
								<img src="${el}" style="width: 100px;height: 100px;margin-bottom:20px;" />
								<input type="checkbox" name="prodDe_check" lay-skin="primary" value="${el}">
							</div>
							
							`
	      		})
	      		console.log("photos",photos)
      		}
//    		多图下载到本地结束
				
				renderForm();
			}, function(data){
				console.log(data)
			})
		}
		
		saveBtn.addEventListener("click",function(){
			sheng = $(".province option:selected").text();
					shi = $(".city option:selected").text();
					qu = $(".Area option:selected").text();
					console.log("qu",qu)
			if($(".province option:selected").text()=="省份"){
				sheng = ''
			}
			if($(".city option:selected").text()=="城市"){
				shi=''
			}
			if($(".Area option:selected").text()=="区域"){
				qu=''
			}
			areas = sheng+shi+qu;
			console.log("A",areas)
					
			_obj.Area = areas;
			_obj.AreaCode = areaCode;
			_obj.FatherId = fatherId;
			
			_obj.RealName=memberName.value;
			_obj.Mobile=memberPhone.value;
			_obj.Company = company.value;
			_obj.Address = addr.value;
			_obj.Position=$(".jobsName option:selected").val();
			_obj.IsRecommend=$(".IsRecommend option:selected").val();
			_obj.Brief = Brief.value;
			_obj.SharedResource = SharedResource.value;
			_obj.DemandResources = DemandResources.value;
			_obj.MultiPhoto = jointPic(photos);
			_obj.WxId = WxId.value;
			_obj.Email = Email.value;
			
			if($(".secJobs option:selected").text()=="请选择"){
				_obj.Trade="";
			}else {
				_obj.Trade=$(".secJobs option:selected").text();
			}
			
			
			
			_obj.TradeId=$(".secJobs option:selected").val();
			
			console.log("_obj",_obj)
			if(params){
				_obj.ModifyUser=localStorage.getItem("user");
				_obj.ModifyTime=getNowFormatDate();
				_obj.MemLoginId=memberId.value;
				DBHelper.Put("Admin_Xn_Member?id="+params.id,_obj,function(data){
					
					console.log(data)
					let index = layer.alert("操作成功",function(){
							window.location.href="#/layui/memberList";
							layer.close(index)
					})
				},
				function(data){
					console.log(data)
				})
			}
			
			
			
		})
		
		
		
})
</script>

<style scoped>
				.small_td{
			width: 100px;
			text-align: right;
		}
		.prodDe_check{
			width: 100px;
			padding: 12px;
			text-align: center;
			display: inline-block;
			/*border: 1px solid black;*/
		}
      	.title{
      		margin-left: 30px;
      		margin-top: 30px;
      	}
      	.save-warp{
      		width: 100%;
      		text-align: center;
      		margin-top: 20px;
      	}
      	.save-warp button{
      		display: inline-block;
      		width: 160px;
      	}
      	.btn{
      		width: 150px;
      	}
      	
      </style>